/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package filetrans;


import View.Panel;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.j3d.View;

/**
 *
 * @author carlosscipione
 */
public class Control implements Runnable {

    private static ServerSocket server;
    private Client client;
    private String filaName;
    private Thread thread;
    private Panel panel;


    public Thread setInstance(String file, Panel panel, Client client) {
        this.filaName=file;
        this.panel = panel;
        this.client=client;
        
        Thread t = new Thread(this);
        this.thread=t;
        t.start();
        return t;

    }

    public void closeServer() {
        try {
            server.close();
        } catch (IOException ex) {
            //nothing
        }
    }

    public void run() {
        try {
            client.download(filaName, thread, panel);
        } catch (Exception ex) {
            Logger.getLogger(Control.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}